﻿/*
 * AddItemController.cs
 * Written by: Shawn Gilleland
 */

using StorageLayer;
using Supply_Fetch;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPLayer
{
    class AddItemController
    {
        private DatabaseManager dbMgr;

        public bool AddItem(Item item, Drawer drawer)
        {
            //check if item name is empty, or if drawer row/column out of bounds, item adding fails
            if (!(item.GetName().Length > 0) || drawer.GetRow() < Constants.MIN_DRAWER_ROW || drawer.GetRow() > Constants.MAX_DRAWER_ROW ||
                drawer.GetColumn() < Constants.MIN_DRAWER_COLUMN || drawer.GetColumn() > Constants.MAX_DRAWER_COLUMN)
                return false;

            return dbMgr.AddItem(item, drawer);
        }

        public AddItemController()
        {
            dbMgr = new DatabaseManager();
        }
    }
}
